<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>element方法</title>
</head>
<body>
    <div id="app" onclick="alert(999)" style="overflow: hidden;color: aqua;">
        <h1>孩子</h1>
    </div>
</body>
<script>
    var d = document.getElementById('app');

    d.setAttribute('app','main')      //给元素设定一个属性为app，值为main

    var a = d.getAttribute('app')     //获取指定元素的指定属性

    d.removeAttribute('app')

    var img = document.createElement('img')

    // d.appendChild(img)

    // var s = d.getAttribute('style')
    // var s = d.getAttribute('onclick')

    var sty = d.onclick

    // console.log(sty); 
    // console.log(s);
    // console.log(a);
    // console.log(d.innerHTML);
    console.log(d.innerText);

    // console.log(d.onclick,'----------------');     //函数

    // console.log(d.getAttribute('onclick','---------------'));   //的字符串

    console.log(d.innerHTML);   //打印元素内容，包括标签名

    console.log(d.innerText);   //打印元素的文本内容

    console.log(d.textContent)  //打印文本内容，不去除空格、换行
</script>
</html>